package com.example.redisstudy1.service;

import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.SessionCallback;

import javax.annotation.Resource;

@SpringBootTest
public class StringTest2 {

    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    @Test
    void get1(){
        Boolean execute = redisTemplate.execute((RedisCallback<Boolean>) connection -> {
            byte[] bytes = connection.get("aname".getBytes());
            System.out.println(bytes);
            System.out.println(new String(bytes));
            return true;
        });
    }


    @Test
     void get2(){
        redisTemplate.execute(new RedisCallback<Boolean>() {
            @Override
            public Boolean doInRedis(RedisConnection connection) throws DataAccessException {

                return null;
            }
        });
    }

    void  get3(){
            redisTemplate.execute((RedisCallback<Boolean>) connection -> {

                return true;
            });
    }


//    RedisAutoConfiguration

}
